import { AxiosResponse } from 'axios';
import { Post } from '../axios';



/* 添加下载码*/
interface addCodeInterface {
    (data: {
        lid: string                   /* 应用id */
        num: number                   /* 创建个数 */
        apptype: string               /* app类型 */
    }): Promise<AxiosResponse<any>>
}
export const addCode: addCodeInterface = async (data) => {
    try {
        return await Post({ url: "/code/incode", data });
    } catch (error) {
        throw error
    }
}

/* 删除下载码*/
interface deCodeAllInterface {
    (data: {
        lid: string                   /* 应用id */
    }): Promise<AxiosResponse<any>>
}
export const deCodeAll: deCodeAllInterface = async (data) => {
    try {
        return await Post({ url: "/code/decodeall", data });
    } catch (error) {
        throw error
    }
}

/* 删除单条下载码*/
interface deCodeOneInterface {
    (data: {
        id: string                   /* 应用id */
    }): Promise<AxiosResponse<any>>
}
export const deCodeOne: deCodeOneInterface = async (data) => {
    try {
        return await Post({ url: "/code/decode", data });
    } catch (error) {
        throw error
    }
}

/* 查询下载码*/
interface getCodeAllInterface {
    (data: {
        lid: string                   /* 应用id */
        pageNo: number                /* 页码 */
        pageSize: number              /* 每页条数 */
    }): Promise<AxiosResponse<any>>
}
export const getCodeAll: getCodeAllInterface = async (data) => {
    try {
        return await Post({ url: "/code/getcodeall", data });
    } catch (error) {
        throw error
    }
}



